
import torch
import json 

with open("./ibsr_res.txt") as f :
    lines = f.readlines()


model_names = ["segresnet", "vnet", "swinunet2d", "transbts", 
                    "densehnet", "unet_plus", "att_unet3d", "att_unet25d", 
                    "att_unet2d", "att_unet3d_ml", "att_unet25d_ml", "att_unet2d_ml",
                    "unet3d", "unet25d", "unet2d", "unet3d_ml", "unet25d_ml", "unet2d_ml",
                    "nnunet", "fuse_unet"]

with open("./ibsr_res_process.txt", "a+") as f1:
    index = 0
    for line in lines:
        pass 
        data = json.loads(line.strip("\n"))
        name = model_names[index]
        save_data = {"name": name, "dices": data["dices"], "hds": data["hds"], "recalls": data["recalls"]}

        f1.write(json.dumps(save_data) + "\n")
        index += 1
